from utils.service import ServiceRouter
from fastapi import UploadFile,File,Form,Request
import os
class uploadFile(ServiceRouter):
    def __init__(self):
        super().__init__(path='/upload')
    async def post(self, chunk_number:int=Form(),total_chunks:int=Form(),filename:str=Form(),file: UploadFile=File(...)):
        data=await self.fileWriter(filename=filename,foldersPath=os.getcwd(),total_chunks=total_chunks,chunk_number=chunk_number,chunk=file)
        return self.res(message=data['message'])
    async def get(self,request:Request):
        response=self.templates.TemplateResponse('file.html',{'request':request})
        return self.res(response=response,cache_bool=True)

